package br.inf.prismasoft.academix.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

import br.inf.prismasoft.academix.entity.types.TipoDuracaoType;

/**
 * Curso generated by hbm2java
 */
@Entity
@Table(name = "CURSO", schema = "ACADEMIX")
public class Curso implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 205277118319075789L;
	private Integer idtCurso;
	private Campus campus;
	private String nomCurso;
	private String desCurso;
	private int numDuracao;
	private TipoDuracaoType indTipoDuracao;
	private Set<GradeCurricular> gradeCurriculars = new HashSet<GradeCurricular>(
			0);
	private Set<Historico> historicos = new HashSet<Historico>(0);

	public Curso() {
	}

	public Curso(Campus campus, String nomCurso, int numDuracao,
			TipoDuracaoType indTipoDuracao) {
		this.campus = campus;
		this.nomCurso = nomCurso;
		this.numDuracao = numDuracao;
		this.indTipoDuracao = indTipoDuracao;
	}

	public Curso(Campus campus, String nomCurso, String desCurso,
			int numDuracao, TipoDuracaoType indTipoDuracao,
			Set<GradeCurricular> gradeCurriculars, Set<Historico> historicos) {
		this.campus = campus;
		this.nomCurso = nomCurso;
		this.desCurso = desCurso;
		this.numDuracao = numDuracao;
		this.indTipoDuracao = indTipoDuracao;
		this.gradeCurriculars = gradeCurriculars;
		this.historicos = historicos;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idt_curso", unique = true, nullable = false)
	public Integer getIdtCurso() {
		return this.idtCurso;
	}

	public void setIdtCurso(Integer idtCurso) {
		this.idtCurso = idtCurso;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_campus", nullable = false)
	@NotNull
	public Campus getCampus() {
		return this.campus;
	}

	public void setCampus(Campus campus) {
		this.campus = campus;
	}

	@Column(name = "nom_curso", nullable = false, length = 50)
	@NotNull
	@Length(max = 50)
	public String getNomCurso() {
		return this.nomCurso;
	}

	public void setNomCurso(String nomCurso) {
		this.nomCurso = nomCurso;
	}

	@Column(name = "des_curso", length = 100)
	@Length(max = 100)
	public String getDesCurso() {
		return this.desCurso;
	}

	public void setDesCurso(String desCurso) {
		this.desCurso = desCurso;
	}

	@Column(name = "num_duracao", nullable = false)
	@NotNull
	public int getNumDuracao() {
		return this.numDuracao;
	}

	public void setNumDuracao(int numDuracao) {
		this.numDuracao = numDuracao;
	}

	@Column(name = "ind_tipo_duracao", nullable = false)
	@Enumerated(EnumType.ORDINAL)
	@NotNull
	public TipoDuracaoType getIndTipoDuracao() {
		return this.indTipoDuracao;
	}

	public void setIndTipoDuracao(TipoDuracaoType indTipoDuracao) {
		this.indTipoDuracao = indTipoDuracao;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "curso")
	public Set<GradeCurricular> getGradeCurriculars() {
		return this.gradeCurriculars;
	}

	public void setGradeCurriculars(Set<GradeCurricular> gradeCurriculars) {
		this.gradeCurriculars = gradeCurriculars;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "curso")
	public Set<Historico> getHistoricos() {
		return this.historicos;
	}

	public void setHistoricos(Set<Historico> historicos) {
		this.historicos = historicos;
	}

}
